#encoding=utf-8
'''
Created on 2018-8-9

@author: cooler
'''
import sys,os
reload(sys)
sys.setdefaultencoding('utf8')
sys.path.append("./")

from catgateio.GateIO import GateIO
from models import *
from key import apiKey,secretKey


def get_pairs():
	gt = GateIO(apiKey,secretKey)
	pairs = gt.pairs()
	for pair in pairs:
		p = Pairs(name=pair.lower())
		p.save()
		print pair

def market_info():
	gt = GateIO(apiKey,secretKey)
	marketinfo_lists = gt.marketinfo()
	for marketinfo in marketinfo_lists['pairs']:
		m = Market_info()
		for k,v in marketinfo.items():
			m.currency_pair = k
			m.decimal_places = v['decimal_places']
			m.min_amount = v['min_amount']
			m.fee = v['fee']
			# print k,v['decimal_places'],type(v['min_amount']),v['fee']
		m.save()
		print marketinfo



if __name__ == '__main__':
    # get_pairs()
    market_info()


